package com.tangyuan.oss.config;

import com.tangyuan.oss.adapter.StorageAdapter;
import com.tangyuan.oss.ossAliyun.adapter.AliStorageAdapter;
import com.tangyuan.oss.ossMinio.adapter.MinioStorageAdapter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: TangYuan
 * @Date: 2024/6/3 16:02
 * @描述: 文件存储config
 */
@Configuration
public class StorageConfig {
    
    @Value("${storage.service.type}")
    private String storageType;
    
    @Bean
    public StorageAdapter storageService() {
        switch (storageType) {
            case "minio":   return new MinioStorageAdapter();
            case "aliyun":  return new AliStorageAdapter();
            default:        throw new IllegalArgumentException("未找到对应的文件存储处理器");
        }
    }
}
